package com.admin.service.impl;

import com.admin.entity.Announcement;
import com.admin.entity.Document;
import com.admin.dao.DocumentMapper;
import com.admin.service.DocumentService;
import com.admin.vo.query.DocumentQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 文件表 服务实现类
 * </p>
 *
 * @author szy
 * @since 2023-03-18
 */
@Service
public class DocumentServiceImpl extends ServiceImpl<DocumentMapper, Document> implements DocumentService {

    @Override
    public IPage<Document> getDocumentByPage(IPage<Document> page, DocumentQueryVo documentQueryVo) {
        QueryWrapper<Document> queryWrapper = new QueryWrapper<Document>();
        //id
        queryWrapper.eq(!ObjectUtils.isEmpty(documentQueryVo.getId()),
                "id",documentQueryVo.getId());
        //标题
        queryWrapper.like(!ObjectUtils.isEmpty(documentQueryVo.getTitle()),
                "title",documentQueryVo.getTitle());
        return baseMapper.selectPage(page,queryWrapper);
    }
}
